<template>
<div id='articletypeitem'>

<Articlesmallitem v-for="(item,index) in info" :key="index" :nickname="info[index]?info[index].nickname:''" :newlist="item" :img_header="info[index]?info[index].author_img:''"></Articlesmallitem>

</div>
</template>

<script>
import {gettypearticle} from "@/network/Forum/forum";
import {get_article_likelist} from "@/network/Likes/Likes";
import {post_article_like} from "@/network/Likes/Likes";
import Articlesmallitem from "@/views/Article/Articlesmallitem";
import {Authormessage} from "@/network/Users/get_info";

export default {
name: "article_item",
  props:{
  ordering:''
  },
  components:{Articlesmallitem},
  data(){
  return{
    title:'',
    info:[],
    userinfo:[],
    new_list:[],
    is_liked:false,
  }
  },
  methods:{
  compare(prop) {
    return function (obj1, obj2) {
        var val1 = obj1[prop];
        var val2 = obj2[prop];
        if (val2 < val1) {
            return -1;
        } else if (val2 > val1) {
            return 1;
        } else {
            return 0;
        }
    }
},
  itemclick(item){
    this.$router.push('article/'+item.id)
  },
    addgood(item){
      post_article_like('forum',item.id).then(
          res=>{
            console.log(res);
          }
      )
    }
  },
  computed:{
  get_like(id){
  }
  },
  beforeCreate() {
  // Authormessage().then(
  //     res=>{
  //       this.authorInfo=res.info
  //     }
  // )
    // this.iid=this.$route.params.iid
  gettypearticle('forum',parseInt(this.$route.params.ordering)+1).then(
      res=>{
        this.info=res.info;

        // console.log(res);
        // this.info.sort(this.compare(this.ordering))
              }

  )

  },
    filters: {
    ellipsis (value) {
      if (!value) return ''
      if (value.length > 20) {
        return value.slice(0,20) + '...'
      }
      return value
    },

      filterHtml(value){
      return value.replace((/<[^>]*>/g))
      }
},
  watch:{

  }
}
</script>

<style scoped>
/*.imgbox{*/
/*  display: flex;*/
/*  height: 160px;*/

/*}*/
.zhushi span{
  margin-left: 12px;
}
.zhushi{
  font-size: 12px;
  color: #a8a8a8;
  position: absolute;
  top: 41px;
left: 74px;
}
.tag_name{
  position: absolute;
  top: 40px;
  left: 30px;
}
.bottom_edit{
  margin-top: 10px;
  text-align: center;
}
.big_item{
  padding: 15px;
  margin-bottom: 10px;
  background-color: white;
  position: relative;
  cursor: pointer;
}
#articleitem{

}
.sex{
  position: relative;
  top: -41px;
  left: 136px;
}
.num{
  margin-left: 4px;
}
.name{
position: absolute;
top: 18px;
left: 75px;
font-size: 14px;
  color: #1CB194;
}
.content_view{
  padding:10px 0px;
  color: #a8a8a8;
  font-size: 14px;
}
.img{
  flex: 1;

  width: 100%;
}
</style>